package com.credithc.signature.core.fadada;

import com.alibaba.fastjson.JSONObject;
import com.credithc.signature.core.service.signprovide.fadada.FadadaSdkClient;
import com.fadada.lightapi.FDDSDKClient;
import com.fadada.lightapi.beans.conformity.register.AccountRegisterReq;
import com.fadada.lightapi.beans.conformity.register.AccountRegisterRsp;
import com.fadada.lightapi.beans.conformity.verfiy.VerCompanyRsp;
import com.fadada.lightapi.beans.conformity.verfiy.VerGetPersonUrlReq;
import com.fadada.lightapi.beans.conformity.verfiy.VerGetUrlRsp;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import sun.misc.BASE64Decoder;

/**
 * @desc: <br/>
 * @author: Jingbo Hu<br/>
 * @time：2020年07⽉07⽇<br/>
 * @version：v1.0.0<br>
 */
@Slf4j
@SpringBootTest
@RunWith(SpringRunner.class)
public class RegisterDemo {

    @Test
    public void test() throws Exception {
        FDDSDKClient client = FadadaSdkClient.initClient();
        AccountRegisterReq req = new AccountRegisterReq();
        req.setOpenId("152322198708231243");
        req.setAccountType(1);
        AccountRegisterRsp rsp = client.register(req);
        log.info(rsp.toString());
    }

    @Test
    public void test1() throws Exception {
        FDDSDKClient client = FadadaSdkClient.initClient();
        VerGetPersonUrlReq person = new VerGetPersonUrlReq();
        person.setCustomerId("D8CF8014856EAA753E25A05AF3610A77");
        person.setPageModify("1");
        person.setNotifyUrl("http://www.baidu.com");
        person.setVerifiedWay("0");
        person.setCustomerIdentNo("152322198708231243");
        person.setCustomerIdentType("0");
        person.setMobile("17603037819");
        person.setCustomerName("张三");
        VerGetUrlRsp rsp = client.verGetPersonUrl(person);
        System.out.println(rsp.toString());
        Object data = rsp.getData();
        JSONObject parse = (JSONObject) JSONObject.parse(data.toString());
        String url = (String) parse.get("url");
        BASE64Decoder base64Decoder = new BASE64Decoder();
        System.out.println(new String(base64Decoder.decodeBuffer(url)));
    }

    @Test
    public void test3() throws Exception {
        FDDSDKClient client = FadadaSdkClient.initClient();
        VerCompanyRsp rsp = client.findVerifyInfo("66b4d95abac6453199fc9ec0add833dd", 1);
        System.out.println(rsp.toString());
    }

}
